from PyQt4.QtGui import QComboBox, QTreeView
from PyQt4.QtCore import Qt, SIGNAL

class ItemList(QTreeView):
    def __init__(self, taskModel):
        super(ItemList, self).__init__()
        self.taskModel = taskModel
        self.setModel(self.taskModel)
        self.expandAll()
        self.setHeaderHidden(True)

def setUpGUI(listModel, taskModel):
    taskWidget = ItemList(taskModel)

    listWidget = QComboBox()
    listWidget.setModel(listModel)

    def f(listName):
        taskWidget.taskModel.setList(listName)
        taskWidget.reset()
        taskWidget.expandAll()

    listWidget.connect(listWidget, SIGNAL('currentIndexChanged(QString)'), f)

    return listWidget, taskWidget

